package com.ibeeking.found.uaa.cp.config.auth.token;

import com.ibeeking.found.common.config.secret.RsaConfig;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.oauth2.provider.token.store.JwtAccessTokenConverter;

import javax.annotation.Resource;
import java.security.KeyPair;

/**
 * @ClassName JwtAccessTokenConverterConfig
 * @Description
 * @Author ibeeking
 * @Date 2020-08-27 16:13
 **/
@Configuration
public class JwtAccessTokenConverterConfig {

    @Resource
    private RsaConfig rsaConfig;

    @Bean
    public JwtAccessTokenConverter accessTokenConverter() {
        final JwtAccessTokenConverter converter = new JwtEnhanceConfig();
        KeyPair keyPair = rsaConfig.getKeyPair();
        converter.setKeyPair(keyPair);
        return converter;
    }
}
